#include <stdio.h>
#include "app_types.h"
#include "mem.h"

static ptr_t nxtMemAddr;
static ptr_t endMemAddr;
static ptr_t startMemAddr;

void init_Mem(ptr_t RamStartAddr, ptr_t RamEndAddr)
{
	startMemAddr = nxtMemAddr = RamStartAddr;
	endMemAddr = RamEndAddr;
}

uint8_t* getMem(uint16_t size)
{
	uint8_t *ptr = NULL;

	if ((nxtMemAddr + size) < endMemAddr)
	{
		ptr = (uint8_t*)nxtMemAddr;
		nxtMemAddr += size;
	}
	return ptr;
}

uint16_t getUsedRam()
{
	return (nxtMemAddr - startMemAddr);
}
